from importlib import import_module
from django.shortcuts import render
from login.middlewares import getEmail
from django.http import HttpResponseRedirect
from register.models import Player
from .models import playerLog

# Create your views here.
def visualization(request):
    email=getEmail(request)
    if email==None:
        return HttpResponseRedirect('/login/')
    # headShot=Player.objects.filter(email=email)[0].headShot.url
    player=playerLog.objects.get(email=email)
    data=[
        [player.logins,'登陆次数'],
        [player.plays,'对局次数'],
        [player.wins,'获胜次数'],
        [player.witness,'观战数']
    ]

    return render(
        request,
        'pie.html',
        {
            'data':data,
            'nickname':Player.objects.filter(email=email)[0].nickname,
            'col':['z','x','c','v','b','n'],
            # 'row':[6,5,4,3,2,1],
            'row':[1,2,3,4,5,6],
            # 'row':[player.logins,player.plays,player.wins,player.witness],
            # 'col':['登陆次数','对局次数','获胜次数','观战数'],
            # 'title':'visualization',
            # 'headShot':headShot,
        },
    )